// 方便api统一管理
import fetchRequest from '../../util/fetchRequest';

const FETCH_ROLE_LIST = '/api/management/config/fetch_role_list'; // 角色列表
const FETCH_ROLE_DETAIL = '/api/management/config/query_role'; // 角色详情
const UPDATE_ROLE = '/api/management/config/update_role'; // 保存(编辑)角色
const FETCH_USER_LIST = '/api/management/config/fetch_user_list'; // 人员列表
const FETCH_ORIGIN_LIST = '/api/management/config/fetch_org_list'; // 组织结构列表
const FETCH_SYNC_DATA_USER = '/api/cron/sync_data_user'; // 同步钉钉人员
const FETCH_SYNC_DATA_ORIGIN = '/api/cron/sync_data_org'; // 同步钉钉部门
const DELETE_ROLE = '/api/management/config/delete_role'; // 删除角色
const FETCH_RULE_LIST = '/api/management/config/fetch_rule_list'; // 打卡规则列表
const FETCH_UPBULATE_DATA = '/api/management/config/rule_tabulate_data'; // 规则数据汇总
const UPDATE_RULE = '/api/management/config/update_rule'; // 添加/编辑打卡设置
const UPDATE_TRAVEL_DAYS ='/api/management/config/update_travel_days'; // 保存人均出差天数
const UPDATE_SET_UP_ROLE = '/api/management/config/set_up_role'; // 设置角色
const UPDATE_CANCEL_SYNC = '/api/management/config/cancel_sync'; // 取消同步
const UPDATE_USER_CONFIG = '/api/management/config/update_user_config'; // 保存同步设置
const FETCH_USER_CONFIG_LIST = '/api/management/config/get_user_config_list'; // 同步设置组织列表

export const fetchRoleList = (companyId, page = 1, num = 10) => fetchRequest(FETCH_ROLE_LIST, { data: { companyId, page, num }, method: 'GET' });
export const fetchRoleDetail = (id) => fetchRequest(FETCH_ROLE_DETAIL, { data: { id }, method: 'GET' });
export const updateRole = (params) => fetchRequest(UPDATE_ROLE, { data: params, method: 'POST' });
export const fetchUserList = (params) => fetchRequest(FETCH_USER_LIST, { data: params, method: 'GET'});
export const fetchOriginList = (params) => fetchRequest(FETCH_ORIGIN_LIST, { data: params, method: 'GET'});
export const fetchSyncDataUser = (params) => fetchRequest(FETCH_SYNC_DATA_USER, { data: params, method: 'GET'});
export const fetchSyncDataOrigin = (params) => fetchRequest(FETCH_SYNC_DATA_ORIGIN, { data: params, method: 'GET'});
export const deleteRole = (params) => fetchRequest(DELETE_ROLE, { data: params, method: 'DELETE' });
export const updateRule = (params) => fetchRequest(UPDATE_RULE, { data: { ...params, rule_type: 1 }, method: 'POST'});
export const updateContributionRule = (params) => fetchRequest(UPDATE_RULE, { data: { ...params, rule_type: 2 }, method: 'POST'}); // 更新贡献值规则
export const fetchRuleList = (params) => fetchRequest(FETCH_RULE_LIST, { data: { ...params, rule_type: 1 }, method: 'GET' }); // 规则列表
export const fetchContributionList = (params) => fetchRequest(FETCH_RULE_LIST, { data: { ...params, rule_type: 2 }, method: 'GET' }); // 贡献列表
export const fetchUpbulateData = (params) => fetchRequest(FETCH_UPBULATE_DATA, { data: params, method: 'GET' });
export const updateTravelDays = (params) => fetchRequest(UPDATE_TRAVEL_DAYS, { data: params, method: 'POST' });
export const upDateSetUpRole = (params) => fetchRequest(UPDATE_SET_UP_ROLE, { data: params, method: 'POST' });
export const upDateCancelSync = (params) => fetchRequest(UPDATE_CANCEL_SYNC, { data: params, method: 'POST' });
export const updateUserConfig = (params) => fetchRequest(UPDATE_USER_CONFIG, { data: params, method: 'POST' });
export const getUserConfigList = (params) => fetchRequest(FETCH_USER_CONFIG_LIST, { data: params });
